import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { GangFightsCreateTeamWindow } from "./GangFightsCreateTeamWindow";
import { ObjCreate } from "../common/ObjCreate";
import { GangFightsFaceCellRenderer } from "./cellRenderer/GangFightsFaceCellRenderer";
import { MsgManager } from "../../manager/MsgManager";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GangFightsTeamFaceData } from "./data/GangFightsTeamFaceData";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTileList } from "../../../../com/mui/controls/GTileList";
//class GangFightsSelectFaceWindow
    
    export  class GangFightsSelectFaceWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(383, 380);
            titleHeight = 26;
            title = Language.getString(44532);
            this.layer = GangFightsCreateTeamWindow.instance;
            this.x = 337;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 38, 347, 290, this);
            this._tileList = ObjCreate.createTileList(35, 62, 320, 264, this);
            this._tileList.columnWidth = 80;
            this._tileList.rowHeight = 88;
            this._tileList.setStyle("cellRenderer", GangFightsFaceCellRenderer);
            this._tileList.dataProvider = this.getFaceDataProvider();
            this._btnSelect = ObjCreate.createGButton(Language.getString(44533), 147, 338, 70, 26, this);
            this._btnSelect.addEventListener(flash.events.MouseEvent.CLICK, this.onClickSelect);
            return;
        }

        /* internal  */onClickSelect(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._tileList.selectedIndex >= 0) 
            {
                GangFightsCreateTeamWindow.instance.faceId = this._tileList.selectedIndex + 1;
                this.hide();
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(44534));
            }
            return;
        }

        /* internal  */getFaceDataProvider(): DataProvider
        {
            var loc3=null;
            var loc1=new Array<any>();
            var loc2=1;
            while (loc2 <= 12) 
            {
                loc3 = new GangFightsTeamFaceData();
                loc3.faceId = loc2;
                loc3.faceBmpName = GameDefConfig.instance.getGangFightsFaceName(loc3.faceId);
                loc1.push(loc3);
                ++loc2;
            }
            return new DataProvider(loc1);
        }

        public static get instance(): GangFightsSelectFaceWindow
        {
            if (!GangFightsSelectFaceWindow._instance) 
            {
                GangFightsSelectFaceWindow._instance = new GangFightsSelectFaceWindow();
            }
            return GangFightsSelectFaceWindow._instance;
        }

        /* internal */ /* var */_btnSelect: GButton;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ static /* var */_instance: GangFightsSelectFaceWindow;
    }
